import os, sys, struct, re
import time
import getopt


ver = 'v4.4'

O26_MVA_Static_Data =  [
	0x4D, 0x56, 0x4F, 0x12, 0x03, 0x01, 0x03, 0x00, 0x00, 0x00, 0x35, 0xBA, 0x69, 0x03, 0xB4, 0x07, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, 0x65, 0x67, 0x15, 0xC1, 0x61, 0xE8, 0x1D, 0xBC, 0x6E, 
	0xC6, 0x1D, 0x41, 0x79, 0x49, 0x2D, 0x44, 0x70, 0xF6, 0x58, 0x7D, 0x24, 0xDD, 0x37, 0x37, 0xA8, 
	0x92, 0x20, 0x8E, 0xB6, 0xCB, 0xBB, 0x3E, 0x54, 0xE5, 0x4B, 0x9D, 0xEC, 0x66, 0x39, 0x5D, 0x0E, 
	0x8F, 0x6E, 0xB6, 0x91, 0x00, 0x7E, 0x56, 0x00, 0xD3, 0xA4, 0x51, 0x0C, 0xA3, 0xEE, 0x3C, 0x5A, 
	0xFB, 0x43, 0x71, 0x35, 0x94, 0x36, 0xB7, 0x87, 0x5C, 0x31, 0x29, 0xCF, 0x82, 0x02, 0xB6, 0xC9, 
	0x87, 0xA9, 0xAC, 0x61, 0x8D, 0x31, 0xF0, 0x7D, 0xE8, 0x31, 0xE5, 0x35, 0xBF, 0x50, 0xFE, 0xAA, 
	0x7E, 0xB8, 0xA3, 0xF0, 0x96, 0x12, 0xAA, 0xDA, 0xFE, 0x68, 0x8E, 0x7E, 0x7D, 0x0F, 0x27, 0x48, 
	0x1C, 0xCF, 0xBB, 0x25, 0xCD, 0xEF, 0x8F, 0x3D, 0x54, 0xD4, 0xBF, 0xE0, 0xA3, 0xBC, 0x1A, 0x23, 
	0x10, 0xEE, 0xC3, 0xEE, 0x11, 0x3F, 0xCD, 0x6D, 0xDF, 0x3E, 0x06, 0x8A, 0x6E, 0x43, 0xDB, 0x60, 
	0xBA, 0xCE, 0x8C, 0x12, 0x41, 0x35, 0x62, 0x23, 0x75, 0x5B, 0x86, 0xE0, 0x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, 0x30, 0x5E, 0xBA, 0x90, 
	0x41, 0x25, 0x3B, 0x45, 0x00, 0x2F, 0x00, 0x14, 0x32, 0x54, 0xE2, 0xAA, 0x06, 0xC9, 0x68, 0x3C, 
	0xAF, 0x32, 0xA4, 0x80, 0x8E, 0x4B
]

CrcCCITTTable = [
    0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
    0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
    0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
    0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
    0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
    0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
    0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
    0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
    0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
    0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
    0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
    0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
    0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
    0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
    0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
    0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
    0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
    0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
    0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
    0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
    0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
    0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
    0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
    0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
    0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
    0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
    0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
    0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
    0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
    0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
    0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
    0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
]

input_file_name = '/'
output_file_name = '/'

def CRC16(Buf, Offset, BufLen, CRC):
    for i in range(0, BufLen):
        CRC = ((CRC << 8) ^ CrcCCITTTable[((CRC >> 8) ^ Buf[i+Offset]) & 0x00FF]) & 0xffff
    return CRC

def get_path():
    # determine if application is a script file or frozen exe
    if getattr(sys, 'frozen', False):
        application_path = os.path.dirname(sys.executable)
    elif __file__:
        application_path = os.path.dirname(__file__)
    return application_path

def usage():
    print ("\nThis is the usage function")
    print ('Usage:')
    print ('-i, --input [] : input *.bin file name')
    print ('-o, --output []: output *.mva file name')

if __name__=="__main__":
    print (time.asctime( time.localtime(time.time()) ))
    print ('mva_maker Tools version %s for MVS SDK (Win or Linux)'%(ver))
    print ('current path: ' + os.path.abspath(get_path()))

    try:
        options,args = getopt.getopt(sys.argv[1:], "hi:o:", ["help","input=","output="])
    except getopt.GetoptError as err:
        usage()
        sys.exit(0)

    for name,value in options:
        if name in ("-h","--help"):
            usage()
            sys.exit(0)
        if name in ("-i","--input"):
            input_file_name = value
        if name in ("-o","--output"):
            output_file_name = value

    input_file_size = os.path.getsize(input_file_name)
    print ("input_file_size = %X"%(input_file_size))
    with open(input_file_name, 'rb') as f:
        inpuDdata = f.read()
    inpuDdata = bytearray(inpuDdata)

    pack_02_buf_with_header = bytearray(bytes(2097152))
    buf_02_Package = bytearray(bytes(9))
    all_crc = bytearray(bytes(4))
    
    for i in range(0, len(pack_02_buf_with_header)):
        pack_02_buf_with_header[i] = 0xff
    
    for i in range(0, len(buf_02_Package)):
        buf_02_Package[i] = 0xff
    
    buf_02_Package[0]=0x02
    buf_02_Package[1]=(input_file_size+4)&0xFF
    buf_02_Package[2]=((input_file_size+4)>>8)&0xFF
    buf_02_Package[3]=((input_file_size+4)>>16)&0xFF
    buf_02_Package[4]=((input_file_size+4)>>24)&0xFF
    buf_02_Package[5]=0x00
    buf_02_Package[6]=0x00
    buf_02_Package[7]=0x00
    buf_02_Package[8]=0x00

    inpuDdata[0xA4]=(input_file_size)&0xFF
    inpuDdata[0xA5]=((input_file_size)>>8)&0xFF
    inpuDdata[0xA6]=((input_file_size)>>16)&0xFF
    inpuDdata[0xA7]=(inpuDdata[0xA4]+inpuDdata[0xA5] +inpuDdata[0xA6]) & 0xFF

    with open(output_file_name, 'wb') as f:
        f.write(bytearray(O26_MVA_Static_Data))

    with open(output_file_name, 'ab+') as f:
        f.write(buf_02_Package)

    tempCRC = 0
    tempCRC =  CRC16(inpuDdata, 0x00, 0xBC, 0)
    tempCRC =  CRC16(inpuDdata, 0xC0, (input_file_size&0x00FFFFFF)-0xC0, tempCRC)

    inpuDdata[0xBC]=(tempCRC)&0xFF
    inpuDdata[0xBD]=((tempCRC)>>8)&0xFF
    inpuDdata[0xBE]=((tempCRC)>>16)&0xFF;   
    inpuDdata[0xBF]=((tempCRC)>>24)&0xFF

    with open(output_file_name, 'ab+') as f:
        f.write(inpuDdata)
    
    tempCRC = 0
    tempCRC =  CRC16(O26_MVA_Static_Data, 0x00, 1990, 0)
    tempCRC =  CRC16(buf_02_Package, 0x00, 0x9, tempCRC)
    tempCRC =  CRC16(inpuDdata, 0x00, input_file_size, tempCRC)
    
    all_crc[0]=(tempCRC)&0xFF
    all_crc[1]=((tempCRC)>>8)&0xFF
    all_crc[2]=((tempCRC)>>16)&0xFF
    all_crc[3]=((tempCRC)>>24)&0xFF

    with open(output_file_name, 'ab+') as f:
        f.write(all_crc)